package com.bestcem.xm.user.service.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * 分页参数入参校验
 *
 * @author XiaoYunSong <ys.xiao@idiaoyan.com>
 * @version v1.0
 * @date 2021/5/11-16:01
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class PageParam {
    /**
     * 当前页
     */
    @NotNull(message = "当前页不能为空")
    @Min(value = 0, message = "当前页不能小于1")
    private Integer page;

    /**
     * 分页大小
     */
    @NotNull(message = "分页大小不能为空")
    @Min(value = 0, message = "分页大小不能小于1")
    @Max(value = 1000, message = "分页大小不能大于1000")
    private Integer size;

    public Integer getStart() {
        return (page - 1) * size;
    }
}
